package com.tgy.servlet;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/***
 * @ClassName: ReadProperties
 * @Description: 读取配置文件
 * @Auther: 送一一块二向箔
 * @Date: 18:52 2021/12/4
 * @version : V1.0
 */
public class ReadProperties extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        InputStream stream = this.getServletContext().getResourceAsStream("/WEB-INF/classes/aa.properties");
        Properties pt = new Properties();
        pt.load(stream);
        String username = pt.getProperty("user");
        String password = pt.getProperty("password");
        resp.getWriter().println(username+":"+password);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}

